package com.vogue.meeting.fluent.entity;

import cn.org.atool.fluent.mybatis.annotation.FluentMybatis;
import cn.org.atool.fluent.mybatis.annotation.GmtCreate;
import cn.org.atool.fluent.mybatis.annotation.GmtModified;
import cn.org.atool.fluent.mybatis.annotation.TableField;
import cn.org.atool.fluent.mybatis.annotation.TableId;
import cn.org.atool.fluent.mybatis.base.RichEntity;

import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * UserEntity: 数据映射实体定义
 *
 * @author Powered By Fluent Mybatis
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@Data
@Accessors(
    chain = true
)
@EqualsAndHashCode(
    callSuper = false
)
@AllArgsConstructor
@NoArgsConstructor
@FluentMybatis(
    table = "user",
    schema = "db_meeting",
    desc = "用户"
)
public class UserEntity extends RichEntity {
  private static final long serialVersionUID = 1L;

  @TableId(
      value = "user_id",
      desc = "用户ID"
  )
  private Integer userId;

  @TableField(
      value = "account",
      desc = "用户账号"
  )
  private String account;

  @TableField(
      value = "email",
      desc = "邮箱"
  )
  private String email;

  @TableField(
      value = "nick_name",
      desc = "用户昵称"
  )
  private String nickName;

  /**
   * 密码字段脱敏==》接口不能返回
   * 1、jackson 使用  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
   * 2、fastjson  使用  @JSONField(serialize = false)
   */
  @TableField(
      value = "password",
      desc = "密码"
  )
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  /*@JSONField(serialize = false)*/
  private String password;

  /**
   * 启用
   */
  @TableField(
          value = "enable",
          desc = "启用"
  )
  private Boolean enable;
  /**
   * 锁定
   */
  @TableField(
          value = "locked",
          desc = "锁定"
  )
  private Boolean locked;

  @TableField(
      value = "create_time",
      insert = "now()",
      desc = "创建时间"
  )
  @GmtCreate
  private LocalDateTime createTime;

  @TableField(
      value = "update_time",
      insert = "now()",
      update = "now()",
      desc = "修改时间"
  )
  @GmtModified
  private LocalDateTime updateTime;

  @Override
  public final Class entityClass() {
    return UserEntity.class;
  }
}
